package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BdPsnjob;
import com.ruoyi.system.service.IBdPsnjobService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 人员任职Controller
 * 
 * @author ruoyi
 * @date 2025-09-08
 */
@Controller
@RequestMapping("/system/psnjob")
public class BdPsnjobController extends BaseController
{
    private String prefix = "system/psnjob";

    @Autowired
    private IBdPsnjobService bdPsnjobService;

    @RequiresPermissions("system:psnjob:view")
    @GetMapping()
    public String psnjob()
    {
        return prefix + "/psnjob";
    }

    /**
     * 查询人员任职列表
     */
    @RequiresPermissions("system:psnjob:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BdPsnjob bdPsnjob)
    {
        startPage();
        List<BdPsnjob> list = bdPsnjobService.selectBdPsnjobList(bdPsnjob);
        return getDataTable(list);
    }

    /**
     * 导出人员任职列表
     */
    @RequiresPermissions("system:psnjob:export")
    @Log(title = "人员任职", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BdPsnjob bdPsnjob)
    {
        List<BdPsnjob> list = bdPsnjobService.selectBdPsnjobList(bdPsnjob);
        ExcelUtil<BdPsnjob> util = new ExcelUtil<BdPsnjob>(BdPsnjob.class);
        return util.exportExcel(list, "人员任职数据");
    }

    /**
     * 新增人员任职
     */
    @RequiresPermissions("system:psnjob:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存人员任职
     */
    @RequiresPermissions("system:psnjob:add")
    @Log(title = "人员任职", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BdPsnjob bdPsnjob)
    {
        return toAjax(bdPsnjobService.insertBdPsnjob(bdPsnjob));
    }

    /**
     * 修改人员任职
     */
    @RequiresPermissions("system:psnjob:edit")
    @GetMapping("/edit/{pkPsnjob}")
    public String edit(@PathVariable("pkPsnjob") String pkPsnjob, ModelMap mmap)
    {
        BdPsnjob bdPsnjob = bdPsnjobService.selectBdPsnjobByPkPsnjob(pkPsnjob);
        mmap.put("bdPsnjob", bdPsnjob);
        return prefix + "/edit";
    }

    /**
     * 修改保存人员任职
     */
    @RequiresPermissions("system:psnjob:edit")
    @Log(title = "人员任职", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BdPsnjob bdPsnjob)
    {
        return toAjax(bdPsnjobService.updateBdPsnjob(bdPsnjob));
    }

    /**
     * 删除人员任职
     */
    @RequiresPermissions("system:psnjob:remove")
    @Log(title = "人员任职", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(bdPsnjobService.deleteBdPsnjobByPkPsnjobs(ids));
    }
}
